package com.isunland.managesystem.ui;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.TextView;
import com.isunland.managesystem.R;

public class MyProgressDialog extends DialogFragment {
  private static final String EXTRA_VALUE =
      "com.isunland.managesystem.ui.ProgressDialog.EXTRA_VALUE";
  private static AlertDialog mDialog;
  private String title = "";

  //	public MyProgressDialog() {}
  //	public MyProgressDialog(String title1) {
  //		super();
  //		title=title1;
  //	}

  //	@Override
  //	public void onCreate(Bundle savedInstanceState) {
  //		title=(String) getArguments().getSerializable(EXTRA_VALUE);
  //		super.onCreate(savedInstanceState);
  //	}

  @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    title = (String) getArguments().getSerializable(EXTRA_VALUE);
    Builder builderSingle = new AlertDialog.Builder(getActivity());
    View v = getActivity().getLayoutInflater().inflate(R.layout.my_progress_dialog, null);
    TextView message = (TextView) v.findViewById(R.id.message);
    message.setText(title);
    builderSingle.setView(v);
    mDialog = builderSingle.create();
    mDialog.setCanceledOnTouchOutside(false);//点击外侧dialog不消失
    return mDialog;
  }

  public static MyProgressDialog newInstence(String title) {
    Bundle bundle = new Bundle();
    bundle.putSerializable(EXTRA_VALUE, title);
    MyProgressDialog dialog = new MyProgressDialog();
    dialog.setArguments(bundle);
    return dialog;
  }
}
